Crate awint_internals[][src]

Expand description

This crate contains common utilities for crates within the awint system. Some of these are highly unsafe macros that were only placed here because #[macro_export] unconditionally causes macros to be publicly accessible. To prevent them from being accessible from intended user-facing crates, this _internals crate was made. The safety requirements of these macros may change over time, so this crate should never be used outside of this system.

Macros

If lhs.bw() != rhs.bw(), this returns None, otherwise f(x, y) is run on every corresponding pair of digits from first to last.

If lhs.bw() != rhs.bw(), this returns None, otherwise f(x, y) is run on every corresponding pair of digits from first to last.

A basic for loop for const contexts

f(x) is run on every digit from first to last.

f(x) is run on every digit from first to last.

Runs f on a digitwise subslice subbits of bits. This is a macro because closures are not properly supported in const functions yet.

Enums

A serialization or deserialization error

Constants

Maximum bitwidth of an inline Awi

Reciprocal binary logarithms of the numbers 2..=36 rounded up and in u16p15 fixed point format

Binary logarithms of the integers 2..=36 rounded up and in u16p13 fixed point format

Maximum value of an inline Awi

Functions

Checks that the BW and LEN values are valid for an InlAwi.

Alternate check for InlAwi invariants

Checks that a raw slice for InlAwi construction is correct. Assumes that assert_inlawi_invariants has already been run to check the correctness of the BW and LEN values.

This is used for quickly calculating the maximum number of bits needed for a string representation of a number in some radix to be represented. This may give more bits than needed, but is guaranteed to never underestimate the number of bits needed. Returns None if we see memory exhaustion

Utility free function for converting a usize to a NonZeroUsize. This is mainly intended for usage with literals, and shouldn’t be used for fallible conversions.

This takes an input of significant bits and gives an upper bound for the number of characters in the given radix needed to represent those bits.

Divides duo by div and returns the quotient and remainder.

Returns the number of whole digits (not including a digit with unused bits) given bw

Returns the number of whole digits (not including a digit with unused bits) given bw

Returns the number of extra bits given bw

Returns the number of extra bits given bw

Returns regular_digits + 1 to account for the bitwidth digit

Returns the number of usize digits needed to represent bw, including any digit with unused bits

Computes x + y + z and returns the widened result as a tuple.

Computes (x * y) + z. This cannot overflow, because it returns the value widened into a tuple, where the first element is the least significant part of the integer and the second is the most significant.